
$(function() {
	
	$("input[id^='emp_']").autocomplete(Test.emp);
	
	$("input[id^='mold_s']:visible").autocomplete(Test.mold);
});

function expenselog(id) {
	var url = 'mold.php?do=ProcessItem.view&id=' + id;
	
	_dialog_view(url, '查看信息', '550x350');
}

var ProcessItem = {
	popup: function (e, p2, id, status) {
		$.cookie('id_', id);

		p2 = query(p2);
		$.cookie('p2', p2);

		var c1 = 'mold.php?do=ProcessItem.edit&id=' + id;
		var c2 = 'mold.php?do=ProcessItem.view&id=' + id;
				
		var a1 = ['编辑信息', 'url', 'ProcessItem.dialog_edit_', '550x350'];	
		var a2 = ['查看信息', 'url', 'Common.dialog_view_', '550x350'];
			
		if (status == '1') {			
			var s = c1 + ", " + c2;

			return popup(e, [a1, a2], s);
		}		

		var s = c2;

		return popup(e, [a2], s);
	},

	dialog_edit_: function (url, title, xy) {
		result = Common.result();
		$.getJSON('mold.php?do=Expense.ajax_emp', function(json) {
			if (json.status == 1) {
				$('#dialog_edit').dialog('option', 'buttons', {
			
					"关闭": function() { 
						$(this).dialog("close");
					},
					
					"提交": function() {
						if (!confirm("确认是否提交？")) {
							return false;
						}
			
						var form = $("#form_edit")[0];
						
						var body = { };
						body.id = form.id.value;
						body.use = form.use.value;
						body.amount = form.amount.value;
						
						$(this).dialog("close");
			
						var url = 'mold.php?do=ProcessItem.editPost';
						var p2 = $.cookie('p2');
						if (p2 != null) {
							url += p2;
						}
			
						$.post(url, body, function(data) {
							$(result).html(data);
						});
					}
				});
			
				dialog_edit(url, title, xy);
			} else {
				_error();
			}
		});
	},
	
	popup_all: function (e, p2) {
		p2 = query(p2);
		$.cookie('p2', p2);

		var c1 = 'mold.php?do=ProcessItem.delete' + p2;		
		var c9 = 'mold.php?do=ProcessItem.xls' + p2;	
			
		var a1 = ['删除信息', 'url', 'Common.list_delete'];				
		var a9 = ['导出Excel', 'url', 'jswin', '1024x768'];

		var s = c1 + ", " + c9;

		return popup(e, [a1, a9], s);
	}
};
